// 根级别的 action
// 封装复杂的 mutations

import * as types from './mutations-type.js'

// 修改user
export const update_user = function ({ commit }, user_id) {
  console.log('update_user::::', user_id)
  window.localStorage.setItem(types.USER_ID, user_id);
  commit(types.USER_ID, user_id)
}

/**修改学生 */
export const update_student = function ({ commit }, student_id) {
  console.log('update_student::::', student_id)
  window.localStorage.setItem(types.STUDENT_ID, student_id);
  commit(types.STUDENT_ID, student_id)
}

/**更新默认学生 */
export const update_default_student = function ({ commit }, student) {
  return new Promise(resolve => {
    window.localStorage.setItem(types.STUDENT, JSON.stringify(student));
    commit(types.STUDENT, student);
    resolve('success');
  })
}
